<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\service\util\GitCode as ServiceGitCode;

/**
 * gitcode接口
 */
class Gitcode extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 获取tag列表
     */
    public function fetch()
    {
        $service = new ServiceGitCode();
        $res = $service->fetch();
        $this->success('请求成功', $res);
    }

    /**
     * 切换tag
     */
    public function checkout()
    {
        $version = $this->request->post('version');
        if(!$version){
            $this->error('请选择版本');
        }
        $service = new ServiceGitCode();
        $res = $service->checkout($version);
        $this->success('请求成功', $res);
    }
}
